package cn.lanqiao.pet;

public abstract class Pet implements Animal{
    //属性
    private String name;
    private String kind;
    private int age;
    private String color;
    private double price;

    //构造方法
    public Pet(String kind, String color) {
        this.name = "未知";
        this.kind = kind;
        this.color = color;
    }

    //成员方法
    @Override
    public void eat(String food){
        System.out.println(name + "吃" + food);
    }

    public abstract String bark();

    public void sleep(){
        System.out.println(name + "睡觉");
    }

    public void play(String ...toy){
        System.out.println(name + "玩" + toy[0]);
    }

    //getter&setter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getKind() {
        return kind;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws AgeException {
        if(age > 20 || age < 0)
           throw new AgeException(age);
        else
            this.age = age;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Pet{" +
                "name='" + name + '\'' +
                ", kind='" + kind + '\'' +
                ", age=" + age +
                ", color='" + color + '\'' +
                ", price=" + price +
                '}';
    }
}
